home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / Install / program files / Borland / BDS / 3.0 / Demos / Delphi.Net / CLR / MapQuest / AboutBox.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2004-10-22  |  5.6 KB  |  166 lines

  1. unit AboutBox;
  2.  
  3. interface
  4.  
  5. uses
  6.   System.Drawing, System.Collections, System.ComponentModel,
  7.   System.Windows.Forms, System.Data, System.Resources;
  8.  
  9. type
  10.   TAboutBox = class(System.Windows.Forms.Form)
  11.   {$REGION 'Designer Managed Code'}
  12.   strict private
  13.     /// <summary>
  14.     /// Required designer variable.
  15.     /// </summary>
  16.     Components: System.ComponentModel.Container;
  17.     ButtonOK: System.Windows.Forms.Button;
  18.     PictureBoxIcon: System.Windows.Forms.PictureBox;
  19.     LabelProductName: System.Windows.Forms.Label;
  20.     LabelProductVersion: System.Windows.Forms.Label;
  21.     LabelAuthor: System.Windows.Forms.Label;
  22.     /// <summary>
  23.     /// Required method for Designer support - do not modify
  24.     /// the contents of this method with the code editor.
  25.     /// </summary>
  26.     procedure InitializeComponent;
  27.     procedure TAboutBox_Load(sender: System.Object; e: System.EventArgs);
  28.   {$ENDREGION}
  29.   strict protected
  30.     /// <summary>
  31.     /// Clean up any resources being used.
  32.     /// </summary>
  33.     procedure Dispose(Disposing: Boolean); override;
  34.   public
  35.     constructor Create;
  36.     class procedure ShowAboutBox;
  37.   end;
  38.  
  39. implementation
  40.  
  41. uses
  42.   System.Globalization, System.Diagnostics;
  43.  
  44. {$REGION 'Windows Form Designer generated code'}
  45. /// <summary>
  46. /// Required method for Designer support - do not modify
  47. /// the contents of this method with the code editor.
  48. /// </summary>
  49. procedure TAboutBox.InitializeComponent;
  50. var
  51.   resources: System.Resources.ResourceManager;
  52. begin
  53.   resources := System.Resources.ResourceManager.Create(TypeOf(TAboutBox));
  54.   Self.ButtonOK := System.Windows.Forms.Button.Create;
  55.   Self.PictureBoxIcon := System.Windows.Forms.PictureBox.Create;
  56.   Self.LabelProductName := System.Windows.Forms.Label.Create;
  57.   Self.LabelProductVersion := System.Windows.Forms.Label.Create;
  58.   Self.LabelAuthor := System.Windows.Forms.Label.Create;
  59.   Self.SuspendLayout;
  60.   // 
  61.   // ButtonOK
  62.   // 
  63.   Self.ButtonOK.DialogResult := System.Windows.Forms.DialogResult.OK;
  64.   Self.ButtonOK.Location := System.Drawing.Point.Create(152, 112);
  65.   Self.ButtonOK.Name := 'ButtonOK';
  66.   Self.ButtonOK.TabIndex := 0;
  67.   Self.ButtonOK.Text := 'OK';
  68.   // 
  69.   // PictureBoxIcon
  70.   // 
  71.   Self.PictureBoxIcon.Image := (System.Drawing.Image(resources.GetObject('PictureBoxIcon.Image')));
  72.   Self.PictureBoxIcon.Location := System.Drawing.Point.Create(8, 16);
  73.   Self.PictureBoxIcon.Name := 'PictureBoxIcon';
  74.   Self.PictureBoxIcon.Size := System.Drawing.Size.Create(32, 32);
  75.   Self.PictureBoxIcon.SizeMode := System.Windows.Forms.PictureBoxSizeMode.AutoSize;
  76.   Self.PictureBoxIcon.TabIndex := 1;
  77.   Self.PictureBoxIcon.TabStop := False;
  78.   // 
  79.   // LabelProductName
  80.   // 
  81.   Self.LabelProductName.AutoSize := True;
  82.   Self.LabelProductName.Font := System.Drawing.Font.Create('Microsoft Sans Serif', 8.25, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (System.Byte(238)));
  83.   Self.LabelProductName.Location := System.Drawing.Point.Create(64, 16);
  84.   Self.LabelProductName.Name := 'LabelProductName';
  85.   Self.LabelProductName.Size := System.Drawing.Size.Create(76, 16);
  86.   Self.LabelProductName.TabIndex := 2;
  87.   Self.LabelProductName.Text := 'ProductName';
  88.   // 
  89.   // LabelProductVersion
  90.   // 
  91.   Self.LabelProductVersion.AutoSize := True;
  92.   Self.LabelProductVersion.Location := System.Drawing.Point.Create(64, 40);
  93.   Self.LabelProductVersion.Name := 'LabelProductVersion';
  94.   Self.LabelProductVersion.Size := System.Drawing.Size.Create(82, 16);
  95.   Self.LabelProductVersion.TabIndex := 3;
  96.   Self.LabelProductVersion.Text := 'ProductVersion';
  97.   // 
  98.   // LabelAuthor
  99.   // 
  100.   Self.LabelAuthor.AutoSize := True;
  101.   Self.LabelAuthor.Location := System.Drawing.Point.Create(64, 64);
  102.   Self.LabelAuthor.Name := 'LabelAuthor';
  103.   Self.LabelAuthor.Size := System.Drawing.Size.Create(38, 16);
  104.   Self.LabelAuthor.TabIndex := 4;
  105.   Self.LabelAuthor.Text := 'Author';
  106.   // 
  107.   // TAboutBox
  108.   // 
  109.   Self.AutoScaleBaseSize := System.Drawing.Size.Create(5, 13);
  110.   Self.ClientSize := System.Drawing.Size.Create(242, 151);
  111.   Self.Controls.Add(Self.LabelAuthor);
  112.   Self.Controls.Add(Self.LabelProductVersion);
  113.   Self.Controls.Add(Self.LabelProductName);
  114.   Self.Controls.Add(Self.PictureBoxIcon);
  115.   Self.Controls.Add(Self.ButtonOK);
  116.   Self.FormBorderStyle := System.Windows.Forms.FormBorderStyle.FixedSingle;
  117.   Self.MaximizeBox := False;
  118.   Self.MinimizeBox := False;
  119.   Self.Name := 'TAboutBox';
  120.   Self.ShowInTaskbar := False;
  121.   Self.StartPosition := System.Windows.Forms.FormStartPosition.CenterScreen;
  122.   Self.Text := 'About ...';
  123.   Include(Self.Load, Self.TAboutBox_Load);
  124.   Self.ResumeLayout(False);
  125. end;
  126. {$ENDREGION}
  127.  
  128. procedure TAboutBox.Dispose(Disposing: Boolean);
  129. begin
  130.   if Disposing then
  131.   begin
  132.     if Components <> nil then
  133.       Components.Dispose();
  134.   end;
  135.   inherited Dispose(Disposing);
  136. end;
  137.  
  138. constructor TAboutBox.Create;
  139. begin
  140.   inherited Create;
  141.   //
  142.   // Required for Windows Form Designer support
  143.   //
  144.   InitializeComponent;
  145.   //
  146.   // TODO: Add any constructor code after InitializeComponent call
  147.   //
  148. end;
  149.  
  150. class procedure TAboutBox.ShowAboutBox;
  151. begin
  152.   TAboutBox.Create.ShowDialog;
  153. end;
  154.  
  155. procedure TAboutBox.TAboutBox_Load(sender: System.Object; e: System.EventArgs);
  156. var
  157.   Version: FileVersionInfo;
  158. begin
  159.   Version := FileVersionInfo.GetVersionInfo(Application.ExecutablePath);
  160.   LabelProductName.Text := Application.ProductName;
  161.   LabelProductVersion.Text := System.String.Format('Version: {0}.{1}', [Version.ProductMajorPart, Version.ProductMinorPart]);
  162.   LabelAuthor.Text := System.String.Format('Author: {0}', [Version.CompanyName]);
  163. end;
  164.  
  165. end.
  166.